package com.github.binarywang.demo.wechat.utils;

import java.util.ArrayList;
import java.util.List;

public class Page<T> {
	private static int PAGE_SIZE = 10;

	public static <T> List<T> getCurrentPage(List<T> sourceList, Integer size) {
		List<T> resultList = new ArrayList<T>();
		if ((size == null) || (Integer.valueOf(size.intValue()).intValue() == 0)) {
			resultList = sourceList.subList(0, PAGE_SIZE > sourceList.size() ? sourceList.size() : PAGE_SIZE);
		} else {
			int extra = sourceList.size() > size.intValue() + PAGE_SIZE ? size.intValue() + PAGE_SIZE
					: sourceList.size();
			resultList = sourceList.subList(0, extra);
		}
		return resultList;
	}
}
